/* verilator lint_off UNUSEDSIGNAL */

import "DPI-C" function void get_cpu(
    input bit en,
	input int pc,
    input int dnpc,
    input int inst,
    input bit load_en,
    input bit store_en,
    input int addr
);

// import "DPI-C" function void get_cpu_inst(
// 	input int inst
// );

// import "DPI-C" function void get_cpu_ls(
// 	input bit load_en,
//     input bit store_en,
//     input int addr
// );

// import "DPI-C" function void get_cpu_csr(
// 	input bit rfc_wen,
//     input int rfc_waddr,
//     input int rfc_wdata
// );

import "DPI-C" function void halt(
	input bit is_halt
);

module DPIC_STAGE(
    input clk,
    input reset,
	
    //debug
    input wb_to_id_bus_t wb_to_id_bus,
    input wb_to_dpic_bus_t wb_to_dpic_bus
);


always_ff @(posedge clk) begin
    if(~reset) begin
        // $display("DPIC_PC=%x,%d\n", wb_to_dpic_bus.debug_pc,wb_to_id_bus.rf_wen|wb_to_id_bus.rfc_wen);
        get_cpu(wb_to_id_bus.rf_wen|wb_to_id_bus.rfc_wen,
                wb_to_dpic_bus.debug_pc,
                wb_to_dpic_bus.debug_dnpc,
                wb_to_dpic_bus.debug_inst,
                wb_to_dpic_bus.debug_load_en,
                wb_to_dpic_bus.debug_store_en,
                wb_to_dpic_bus.debug_ls_addr);
        // get_cpu_inst(wb_to_dpic_bus.debug_inst);
        // get_cpu_ls(wb_to_dpic_bus.debug_load_en,wb_to_dpic_bus.debug_store_en,wb_to_dpic_bus.debug_ls_addr);
        // get_cpu_csr(wb_to_id_bus.rfc_wen,{20'b0,wb_to_id_bus.rfc_waddr},wb_to_id_bus.rfc_wdata);
    end
end

always_comb begin
    if(reset) begin
        halt(1'b0);
    end else begin
        halt(wb_to_dpic_bus.debug_ebreak_en);
    end
end

endmodule
